<template>
  <div >
    <el-row >
      <span style="font-size: 15pt;font-weight: 100;color: black;">欢迎您：{{name}}</span>

      <el-button type="danger" size="small" round @click="logout">退出</el-button>

      <el-button round @click="user">ROLE_user角色</el-button>
      <el-button type="primary" round @click="root">ROLE_root角色</el-button>
      <el-button type="success" round @click="select">查询权限</el-button>
      <el-button type="info" round @click="update">修改权限</el-button>
      <el-button type="warning" round @click="insert">添加权限</el-button>
      <el-button type="danger" round @click="deleted">删除权限</el-button>
    </el-row>
  </div>
</template>

<script>
export default {
  data() {
    return {
      name: '',
    };
  },
  created() { //钩子函数页面加载完调用
    this.getToken()
  },
  methods: {
    logout() {
      this.$store.commit('del_token');
      this.$router.push({
        name: 'Login'
      })
    },
    getToken() {
      this.name = sessionStorage.getItem('username');
    },
    user() {
      this.$httpApi.get('http://localhost:8088/user')
          .then(res => {
            if (res.data == '没有权限进行该操作') {
              this.$message.error("没有权限进行该操作");
            } else {
              this.$message.success(res.data);
            }
          });
    },
    root() {
      this.$httpApi.get('http://localhost:8088/root')
          .then(res => {
            if (res.data == '没有权限进行该操作') {
              this.$message.error("没有权限进行该操作");
            } else {
              this.$message.success(res.data);
            }
          });
    },
    select() {
      this.$httpApi.get('http://localhost:8088/select')
          .then(res => {
            if (res.data == '没有权限进行该操作') {
              this.$message.error("没有权限进行该操作");
            } else {
              this.$message.success(res.data);
            }
          });
    },
    update() {
      this.$httpApi.get('http://localhost:8088/update')
          .then(res => {
            if (res.data == '没有权限进行该操作') {
              this.$message.error("没有权限进行该操作");
            } else {
              this.$message.success(res.data);
            }
          });
    },
    insert() {
      this.$httpApi.get('http://localhost:8088/insert')
          .then(res => {
            if (res.data == '没有权限进行该操作') {
              this.$message.error("没有权限进行该操作");
            } else {
              this.$message.success(res.data);
            }
          });
    },
    deleted() {
      this.$httpApi.get('http://localhost:8088/deleted')
          .then(res => {
            if (res.data == '没有权限进行该操作') {
              this.$message.error("没有权限进行该操作");
            } else {
              this.$message.success(res.data);
            }
          });
    }
  }
};
</script>

<style>
</style>
